/*
 * @Author: wuyuzhang 382795819@qq.com
 * @Date: 2025-09-18 16:40:39
 * @LastEditors: wuyuzhang 382795819@qq.com
 * @LastEditTime: 2025-10-11 19:57:56
 * @FilePath: \newbee-mall-vue-app\src\service\order.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */

import axios from '../utils/axios'

export function createOrder(params) {
  return axios.post('/saveOrder', params);
}

export function getOrderList(params) {
  return axios.get('/order', { params });
}

export function getOrderDetail(id) {
  return axios.get(`/order/${id}`);
}

export function cancelOrder(id) {
  return axios.put(`/order/${id}/cancel`);
}

export function confirmOrder(id) {
  return axios.put(`/order/${id}/finish`)
}

export function payOrder(params) {
  return axios.get('/paySuccess', { params })
}

// 获取快递费配置
export const getDeliveryFeeConfig = () => {
  return axios.get('/deliveryFee/config')
}


// 新增物流信息接口
export function getOrderLogistics(orderNo) {
  return axios.get(`/order/queryRouteByWaybill/${orderNo}`)
    .then(response => {
      return response;
    })
    .catch(error => {
      throw error;
    });
}

export function payWxOrder(params) {
  return axios.post('/pay', params)
    .then(response => {
      window.location.href = response.message; // 跳转到支付页面

    })
    .catch(error => {
      throw error;
    });
}

// 在 order.js 中添加以下方法

// 申请开票
export const applyInvoice = (params) => {
  return axios.post('/applyInvoice', params)
    .then(response => {
      return response;
    })
    .catch(error => {
      throw error;
    });
};

// 申请退款
export const applyRefund = (params) => {
  return axios.post('/applyRefund', params)
    .then(response => {
      return response;
    })
    .catch(error => {
      throw error;
    });
};

// 开具发票
export function newBill(params) {
  return axios.post('/newBill', params)
    .then(response => {
      return response;
    })
    .catch(error => {
      throw error;
    });
}

// 查询发票结果
export function selectBill(orderNo) {
  return axios.post('/selectBill', { "orderNo":orderNo })
    .then(response => {
      return response;
    })
    .catch(error => {
      throw error;
    });
}




